home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / clipasc.arc / ASCSCAN.MAC next >
Text File  |  1987-03-17  |  3KB  |  188 lines

  1. ;----------------------------------------------------------------
  2. ;    ASCSCAN - Header file for CLIPASC
  3. ; Description:
  4. ;    ASCSCAN performs all macro definitions and general
  5. ;    equates for CLIPASC
  6. ;----------------------------------------------------------------
  7.  
  8.     extrn    _parinfo:far
  9.     extrn    _parc:far
  10.     extrn    _parni:far
  11.     extrn    _parnl:far
  12.     extrn    _pards:far
  13.     extrn    _parl:far
  14.  
  15.     extrn    _retc:far
  16.     extrn    _retni:far
  17.     extrn    _retnl:far
  18.     extrn    _retds:far
  19.     extrn    _retl:far
  20.  
  21. ;------ Equates for type
  22.  
  23. undef        equ    0
  24. character    equ    1
  25. numeric     equ    2
  26. logical     equ    4
  27. date        equ    8
  28. optional    equ    8000h        ; additional flag for parm type
  29.  
  30. ;------ get number of parms passed--returned in AX
  31.  
  32. get_pcount    macro
  33.     xor    ax,ax
  34.     push    ax
  35.     call    _parinfo
  36.     add    sp,2
  37.     endm
  38.  
  39. ;------ get type of requested parm--returned in AX
  40.  
  41. get_ptype    macro    n
  42.     mov    ax,n
  43.     push    ax
  44.     call    _parinfo
  45.     add    sp,2
  46.     endm
  47.  
  48. ;------ get requested parm as string--returns segment and offset in AX:BX
  49.  
  50. get_char    macro    n
  51.     mov    ax,n
  52.     push    ax
  53.     call    _parc
  54.     add    sp,2
  55.     endm
  56.  
  57. ;------ get requested parm as integer--returned in AX
  58.  
  59. get_int     macro    n
  60.     mov    ax,n
  61.     push    ax
  62.     call    _parni
  63.     add    sp,2
  64.     endm
  65.  
  66. ;------ get requested parm as long integer--returned in AX:BX
  67.  
  68. get_long    macro    n
  69.     mov    ax,n
  70.     push    ax
  71.     call    _parnl
  72.     add    sp,2
  73.     endm
  74.  
  75. ;------ get requested parm as date string--returns segment and offset as AX:BX
  76.  
  77. get_datestr    macro    n
  78.     mov    ax,n
  79.     push    ax
  80.     call    _pards
  81.     add    sp,2
  82.     endm
  83.  
  84. ;------ get requested parm as logical true or false--returned in AX
  85.  
  86. get_logical    macro    n
  87.     mov    ax,n
  88.     push    ax
  89.     call    _parl
  90.     add    sp,2
  91.     endm
  92.  
  93. ;------ return char pointer in REG1:REG2
  94.  
  95. ret_char    macro    reg1,reg2
  96.     irp    x,<reg1,reg2>
  97.     push    x
  98.     endm
  99.     call    _retc
  100.     add    sp,4
  101.     endm
  102.  
  103. ;------ return integer in REG1
  104.  
  105. ret_int macro    reg1
  106.     push    reg1
  107.     call    _retni
  108.     add    sp,2
  109.     endm
  110.  
  111. ;------ return long integer in REG1:REG2
  112.  
  113. ret_long    macro    reg1,reg2
  114.     irp    x,<reg1,reg2>
  115.     push    x
  116.     endm
  117.     call    _retnl
  118.     add    sp,4
  119.     endm
  120.  
  121. ;------ return date string pointed to by REG1:REG2
  122.  
  123. ret_datestr    macro    reg1,reg2    ; return pointer to date string
  124.                     ; in reg1:reg2
  125.     irp    x,<reg1,reg2>
  126.     push    x
  127.     endm
  128.     call    _retds
  129.     add    sp,4
  130.     endm
  131.  
  132. ;------ return logical true (1) or false (0) in REG1
  133.  
  134. ret_logical    macro    reg1        ; return 1 or 0 in reg1
  135.     push    reg1
  136.     call    _retl
  137.     add    sp,2
  138.     endm
  139.  
  140. ;------ End of Clipper dependent macros
  141.  
  142. parm_chk    macro    scan_loc,ret_addr
  143.     local    chk_1,chk_fail,chk_2
  144.  
  145.     mov    cx,&scan_loc        ; get max number of parms
  146.  
  147.     get_pcount
  148.     mov    si,offset &scan_loc + 2 ; want second word at loc
  149.  
  150.     cmp    ax,cx            ; greater than max number?
  151.     jle    chk_1
  152.  
  153.     mov    ax,err_inv_parms    ; return code
  154.     jmp    &ret_addr
  155.  
  156. chk_1:
  157.     push    cx            ; save which parm we're on
  158.     push    si
  159.     mov    ax,&scan_loc
  160.     sub    ax,cx
  161.     inc    ax            ; get parm number to check
  162.     push    ax
  163.     call    _parinfo        ; well, what is it?
  164.  
  165.     pop    dx            ; save stored AX
  166.     pop    si
  167.     mov    bx,ax            ; what we got back
  168.     lodsw                ; get what it should be
  169.     cmp    al,bl            ; did we get what we wanted. Only check
  170.                     ; the low byte. High byte are flags
  171.     je    chk_2            ; yes, don't worry about it
  172.  
  173.     test    ax,optional        ; could they skip it?
  174.     jz    chk_fail
  175.     cmp    bx,undef        ; did they skip it?
  176.     je    chk_2            ; oh, that's cool, then.
  177.  
  178. chk_fail:
  179.     mov    ax,dx
  180.     pop    cx            ; throw away saved CX
  181.     add    ax,err_parms_base
  182.     jmp    &ret_addr
  183.  
  184. chk_2:
  185.     pop    cx            ; restore number left to check
  186.     loop    chk_1            ; and try it again
  187.     endm
  188.